<template>
  <div class="fans">
    <el-table :data="Lists" border style="width: 100%,height:100%">
      <el-table-column prop="id" label="id"></el-table-column>
      <el-table-column prop="nickname" label="昵称"></el-table-column>
      <el-table-column prop="username" label="账号"></el-table-column>
      <el-table-column fixed="right" label="操作">
        <template slot-scope="scope">
          <el-button
            @click="handleCancel(scope.row.id)"
            type="danger"
            size="mini"
          >取消关注</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import concernApi from "@/api/concern.js";
export default {
  data() {
    return {
      Lists: [
          {id:1,nickname:"c",username:"ok",password:"..."},
          {id:2,nickname:"c",username:"no",password:"..."},
      ],
      pojo: {}, //提交的数据
    };
  },

  created() {
    this.fetchData();
  },

  methods: {
    fetchData() {
      concernApi.myConcern().then(response => {
        // const res = response.data;
        // this.list = res.data;
        console.log(response.data)
        this.Lists = response.data;
      });
    },
    handleCancel(id){
        console.log(id);
        this.$confirm("确认取消关注吗?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(() => {
          concernApi.deleteById(id).then(response=>{
              const resp = response.data;
              if(resp.flag){
                  this.fetchData();
              }
          })
        }).catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除"
          });
        });
    },
  }
};
</script>

<style scoped>
.fans {
  position: absolute;
  /* left: 46%; */
  width: 100%;
  top: 60px;
  /* text-align: center; */
}
.el-form {
  /* position:absolute; */
  width: 100%;
}
</style>